#pragma once
#ifndef SDEF_GRAPH
#define SDEF_GRAPH

#include <SypX/SypX.h>
#include "Node.h"
#include "Instances.h"

namespace SheepDefence
{
	class Level;

	class Graph
	{

	public:

		struct nodeComparator
		{
			bool operator()(Node* a, Node* b)
			{
				return a->point < b->point;
			}
		};

		struct nodeSharedComparator
		{
			bool operator()(Node* a, Node* b)
			{
				return a->shared < b->shared;
			}
		};
		
		struct nodeSharedHungryComparator
		{
			bool operator()(Node* a, Node* b)
			{
				return a->sharedHungry < b->sharedHungry;
			}
		};

		Level* owner;

		std::vector<Node*> nodes;

		float age;

		Graph();

		~Graph();

		Graph(int num_nodes, Level* lvl);

		void updateLevel(Level* lvl);

		void update();

		SypX::Vec2 getDest(WolfInstance* wolf, DogInstance* dog, std::vector<SheepInstance*>& sheep, std::vector<ObstacleInstance*>& obstacles);
		SypX::Vec2 getDest(WolfInstance* wolf, std::vector<SheepInstance*>& sheep, std::vector<ObstacleInstance*>& obstacles);	// ignore dog
		SypX::Vec2 getDest(float start_x, float start_y, float end_x, float end_y, std::vector<ObstacleInstance*>& obstacles, float size);
		SypX::Vec2 getDest(float start_x, float start_y, float end_x, float end_y, std::vector<ObstacleInstance*>& obstacles, float size, std::vector<ObstacleInstance*>& exceptions);
		
		void setup(std::vector<WolfInstance*>& wolves, DogInstance* dog, std::vector<SheepInstance*>& sheep, std::vector<ObstacleInstance*>& obstacles, float time);
		SypX::Vec2 getDest(WolfInstance* wolf, DogInstance* dog, std::vector<ObstacleInstance*>& obstacles);
		SypX::Vec2 getDest(WolfInstance* wolf, std::vector<ObstacleInstance*>& obstacles);
	};
}
#endif